import openpyxl



wb = openpyxl.Workbook()

ws = wb.active# 当前打开的sheet页 wb.active

ws.title = "WorkSheetTitle"#更改默认名称Sheet`

# 给单元格赋值
ws["A1"] = "HOGE"
ws["B1"] = "FUGA"


# 指定行列给单元格赋值
v = 0
for i in range(1, 10):
    for n in range(1, 10):
        ws.cell(row=i, column=n, value=v)
        v += 1


# ws.cell(row=4, column=2, value=10)# 指定行列给单元格赋值

ws2 = wb.create_sheet("NewWorkSheet2")# 定义第二个sheet页
ws3 = wb.create_sheet("NewWorkSheet3", 0)# 定义第三个sheet页,# `0` 的设定 会将该sheet页 置于wb最前面



wb.save('d:/example2023.xlsx')# 保存

from openpyxl import Workbook, load_workbook

wb = load_workbook('d:/example.xlsx')
ws = wb.active
print(ws) #获取sheet标题内容
for row in ws:
    for cell in row:
        print(cell.value)